/**
 * Created by yumeng on 2017/11/17.
 */
define([
  './themes/lang/' + window.YUFP_SYS_CONFIG.language + '/pages/example/template/exampleSteps1.js'
], function (require, exports) {
  // page加载完成后调用ready方法
  exports.ready = function (hashCode, data, cite) {
    // 创建virtual model
    var vm = yufp.custom.vue({
      el: '#exampleSteps1',
      // 以m_开头的属性为UI数据不作为业务数据，否则为业务数据
      data: function () {
        var me = this;
        return {
          active: 0,
          step: true,
          step1: false,
          step2: false,
          editFields: [{
            columnCount: 2,
            fields: [
              { field: 'name',
                label: this.$t('exampleSteps1.xm'),
                placeholder: this.$t('exampleSteps1.dgzf'),
                type: 'input',
                rules: [{ required: true, message: this.$t('exampleSteps1.qsrxm'), trigger: 'blur' },
                  { min: 2, max: 10, message: this.$t('exampleSteps1.cdzdgzf'), trigger: 'blur' }]
              },
              { field: 'education',
                label: this.$t('exampleSteps1.xl'),
                type: 'select',
                dataCode: 'EDUCATION_TYPE',
                rules: [{ required: true, message: this.$t('exampleSteps1.qxzxl'), trigger: 'change' }]
              },
              { field: 'sex',
                label: this.$t('exampleSteps1.xb'),
                type: 'radio',
                dataCode: 'GENDER',
                rules: [{ required: true, message: this.$t('exampleSteps1.qxzxb'), trigger: 'change' }]
              },
              { field: 'idCard',
                label: this.$t('exampleSteps1.zjlx'),
                type: 'select',
                dataCode: 'IDENT_TYPE',
                rules: [{required: true, message: this.$t('exampleSteps1.qxzzjlx'), trigger: 'change'}]
              },
              { field: 'birthday',
                label: this.$t('exampleSteps1.csrq'),
                type: 'date',
                placeholder: this.$t('exampleSteps1.csrq'),
                rules: [{type: 'date', required: true, message: this.$t('exampleSteps1.qxzcsrq'), trigger: 'blur'}]
              },
              { field: 'idNumber',
                label: this.$t('exampleSteps1.zjhm'),
                type: 'input',
                placeholder: this.$t('exampleSteps1.zjhm'),
                rules: [{ required: true, message: this.$t('exampleSteps1.qsrzjhm'), trigger: 'blur' }]
              },
              { field: 'company', label: this.$t('exampleSteps1.szgs'), type: 'input', placeholder: this.$t('exampleSteps1.gsmc')},
              { field: 'mobileNumber', label: this.$t('exampleSteps1.sjhm'), type: 'input', placeholder: this.$t('exampleSteps1.sjhm')}
            ]
          }, {
            columnCount: 1,
            fields: [
              { field: 'remark', label: this.$t('exampleSteps1.bz'), placeholder: this.$t('exampleSteps1.gzfyn'), type: 'textarea', rows: 6 }
            ]
          }],
          buttons: [
            {label: this.$t('exampleSteps1.qx'),
              type: 'primary',
              icon: 'yx-undo2',
              click: function () {
              // do something
              }},
            {label: this.$t('exampleSteps1.xyb'),
              type: 'primary',
              icon: 'check',
              op: 'submit',
              click: function (model, valid) {
                if (valid) {
                  me.$msgbox.alert(model, me.$t('exampleSteps1.ts'));
                  // do something
                  me.step = false;
                  me.step1 = true;
                  me.active++;
                }
              }},
            {label: this.$t('exampleSteps1.zz'),
              type: 'primary',
              icon: 'yx-loop2',
              op: 'reset',
              click: function (model) {
              // do something
              }}
          ],

          // setp1 form
          editFields1: [{
            columnCount: 2,
            fields: [
              { field: 'address',
                label: this.$t('exampleSteps1.jzdz'),
                placeholder: this.$t('exampleSteps1.dgzf'),
                type: 'input',
                rules: [{ required: true, message: this.$t('exampleSteps1.qsrjzdz'), trigger: 'blur' },
                  { min: 5, max: 30, message: this.$t('exampleSteps1.dgzf'), trigger: 'blur' }]
              },
              { field: 'status',
                label: this.$t('exampleSteps1.hjzt'),
                type: 'radio',
                dataCode: 'USER_STATUS',
                rules: [{ required: true, message: this.$t('exampleSteps1.hjzt'), trigger: 'change' }]
              },
              { field: 'date',
                label: this.$t('exampleSteps1.gxrq'),
                type: 'date',
                placeholder: this.$t('exampleSteps1.zhycgxrq'),
                rules: [{type: 'date', required: true, message: this.$t('exampleSteps1.qxzgxrq'), trigger: 'blur'}]
              },
              { field: 'number',
                label: this.$t('exampleSteps1.rksl'),
                type: 'input',
                placeholder: this.$t('exampleSteps1.rksl'),
                rules: [{ required: true, message: this.$t('exampleSteps1.qsrrksl'), trigger: 'blur' }]
              },
              { field: 'telNumber', label: this.$t('exampleSteps1.lxdh'), type: 'input', placeholder: this.$t('exampleSteps1.lxdh')},
              { field: 'postalCode', label: this.$t('exampleSteps1.yzbm'), type: 'input', placeholder: this.$t('exampleSteps1.yzbm')}
            ]
          }],
          buttons1: [
            {label: this.$t('exampleSteps1.syb'),
              type: 'primary',
              icon: 'yx-undo2',
              click: function () {
              // do something
                me.step = true;
                me.step1 = false;
                me.active--;
              }},
            {label: this.$t('exampleSteps1.xyb'),
              type: 'primary',
              icon: 'check',
              op: 'submit',
              click: function (model, valid) {
                if (valid) {
                  me.$msgbox.alert(model, me.$t('exampleSteps1.ts'));
                  // do something
                  me.step1 = false;
                  me.step2 = true;
                  me.active++;
                }
              }},
            {label: this.$t('exampleSteps1.zz'),
              type: 'primary',
              icon: 'yx-loop2',
              op: 'reset',
              click: function (model) {
              // do something
              }}
          ],

          // setp2 form
          editFields2: [{
            columnCount: 2,
            fields: [
              { field: 'comAddress',
                label: this.$t('exampleSteps1.gsdz'),
                placeholder: this.$t('exampleSteps1.dgzf'),
                type: 'input',
                rules: [{ required: true, message: this.$t('exampleSteps1.qsrgsdz'), trigger: 'blur' },
                  { min: 5, max: 30, message: this.$t('exampleSteps1.dgzf'), trigger: 'blur' }]
              },
              { field: 'comStatus',
                label: this.$t('exampleSteps1.gslx'),
                type: 'radio',
                dataCode: 'CUST_TYPE',
                rules: [{ required: true, message: this.$t('exampleSteps1.gslx'), trigger: 'change' }]
              },
              { field: 'comTelNumber', label: this.$t('exampleSteps1.lxdh'), type: 'input', placeholder: this.$t('exampleSteps1.lxdh')},
              { field: 'comPostalCode', label: this.$t('exampleSteps1.yzbm'), type: 'input', placeholder: this.$t('exampleSteps1.yzbm')}
            ]
          }],
          buttons2: [
            {label: this.$t('exampleSteps1.syb'),
              type: 'primary',
              icon: 'yx-undo2',
              click: function () {
              // do something
              // do something
                me.step1 = true;
                me.step2 = false;
                me.active--;
              }},
            {label: this.$t('exampleSteps1.tj'),
              type: 'primary',
              icon: 'check',
              op: 'submit',
              click: function (model, valid) {
                if (valid) {
                  me.$msgbox.alert(model, me.$t('exampleSteps1.ts'));
                  // do something
                  me.active++;
                }
              }},
            {label: this.$t('exampleSteps1.zz'),
              type: 'primary',
              icon: 'yx-loop2',
              op: 'reset',
              click: function (model) {
              // do something
              }}
          ]
        };
      },
      mounted: function () {

      },
      methods: {

      }
    });
  };

  // 消息处理
  exports.onmessage = function (type, message) {

  };

  // page销毁时触发destroy方法
  exports.destroy = function (id, cite) {

  };
});
